<!DOCTYPE html>
<html>
  <head>
    <meta charset='utf-8'>
    <meta http-equiv="X-UA-Compatible" content="chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">

    <!-- <link rel="stylesheet" type="text/css" href="http://caifengye.cn//static/lib/layuiadmin/layui/css/layui.css"> -->
    <link rel="stylesheet" type="text/css" href="https://yiyuan.dabannet.cn/static/plugins/layui/css/layui.css">
    <link rel="stylesheet" type="text/css" href="https://yiyuan.dabannet.cn/static/common/css/font.css">

    <title>calendar</title>
    <style>

.sc-calendar {
  width: 500px;
  height: 500px;
  text-align: center;
  font-family: "Microsoft Yahei";
  color: #4A4A4A;
  box-shadow: 2px 4px 5px #bdbdbd;
  border-width: 1px 0 0 1px;
  border-color: #E6E4E0;
  border-style: solid;
  float: left;
  margin-right: 20px;
  -moz-user-select: none;
  /*火狐*/
  -webkit-user-select: none;
  /*webkit浏览器*/
  -ms-user-select: none;
  /*IE10*/
  user-select: none;
  -webkit-text-size-adjust: none;
  font-size: 16px;
}

.sc-header {
  /*height: 35px;*/
  border-bottom: 0;
    font-size: 20px;padding: 10px 0;
    float: left;width: 100%;
}
.sc-body {
  /*height: 93%;*/
  clear: both;
  /*box-shadow: 2px 4px 5px #bdbdbd;*/
}
.sc-week {
  /*height: 12%;*/
  height: 36px;
  line-height: 36px;
  font-weight: 400;
  font-size: 16px;
  color: #4A4A4A;
}
.sc-days {
  /*height: 88%;*/
}
.sc-item {
  /*height: 20%;*/
  height: 84px;
  float: left;
  font-weight: 600;
  color: #565555;
  width: 14.285%;
  padding-top: 10px;
  background-color: #ffffff;
  border-width: 0 0 1px 1px;
  border-color: #F1EBE4;
  border-style: solid;
  box-sizing: border-box;
}
.item-nolunar {
  padding-top: 20px;
}
.sc-item:nth-child(7n) .day, .sc-item:nth-child(7n+6) .day {
  color: rgba(224, 8, 8, 0.74);
}
.sc-vocation {
  background-color: #FFEBEC;
}
.sc-mark{
  background-color: #E5FBFA;
}
.sc-vocation:before {
  content: '休';
  display: block;
  position: absolute;
  font-size: 0.7em;
  width: 1.2em;
  font-weight: 100;
  color: white;
  background-color: #E00808;
  margin-top: -10px;
}
.sc-othermenth {
  color: #C1C0C0 !important;
  /* opacity: .4; */
}
.sc-othermenth .day, .sc-othermenth .lunar-day {
  /*color: #C1C0C0 !important;*/
}
.sc-active-day, .sc-selected {
  border: 1px solid orange;
}
.sc-today {
/*  background-color: orange;
  color: white;
  border: 1px solid orange;*/
}
.sc-item .day {
  font-size: 1.5em;
}
.sc-today .day {
  /*color: white !important;*/
}
.sc-item .lunar-day {
  font-size: 10px;
  font-weight: normal;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sc-festival .lunar-day {
  color: #E00808;
}

/*.sc-item:last-child, .sc-item:nth-child(7n) {
  border-width: 0 1px 1px 1px;
}*/

.sc-week-item {
  height: 100%;
  /*padding-top: 2%;*/
  float: left;
  width: 14.285%;
  background-color: #FBEC9C;
  border-width: 1px 0 1px 1px;
  border-color: #ECE3B1;
  border-style: solid;
  box-sizing: border-box;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sc-item-small{
  font-size: 10px !important;
}
.sc-week-item:last-child {
  border-width: 1px 1px 1px 1px;
}
.sc-week-item:nth-child(7n), .sc-week-item:nth-child(7n+6) {
  color: rgba(224, 8, 8, 0.74)!important;
}
.sc-actions {
  float: left;
  width: 25%;
  /*padding: 5px;*/
  height: 100%;
  box-sizing: border-box;
}
.sc-actions:last-child {
  float: right;
}
.sc-actions-big{
  width: 50%;
}
@media screen and (max-width : 500px){
.sc-actions{
  width: 50%;
}
}
.sc-header select {
/*  border-color: rgba(0, 0, 0, 0);
  padding: 0.2em;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  font-family: "Microsoft Yahei";
  color: #606060;
  font-size: 13px ;*/
}
.sc-header input {
  border-color: rgba(0, 0, 0, 0);
  padding: 0.2em;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  font-family: "Microsoft Yahei";
  color: #606060;
}
.sc-actions div {
  display: inline-block;
  /*border: 1px solid #ccc;*/
  /*vertical-align: bottom;*/
  width: 20px;
  /*padding-bottom: 5px;*/
  /*font-size: 1.5em;*/
  /*line-height: 0.9em;*/
}
.sc-actions .sc-yleft,.sc-actions .sc-yright{
    display: none;
}

.sc-actions .sc-mleft,.sc-actions .sc-mright{
    position: relative;font-size: 0;
}
.sc-actions .sc-mleft::after,.sc-actions .sc-mright:after{
    font-size: 20px;
}
.sc-actions .sc-mleft:after{
    content: "<";
}
.sc-actions .sc-mright:after{
    content: ">";
}
.sc-return-today {
  display: block;
  background-color: #F5F5F9;
  border-radius: 2px;
  /* border: 1px solid #ccc; */
  width: 60px;
  font-size: 0.8em;
  padding: 0.3em;
  margin: auto;
}

.sc-time {
  display: block;
  margin-top: 3px;
  font-size: 0.8em;
}



    /*.inner{width: 1050px;margin: 0 20px;}*/
      #calendar{width: 100%}
      .clearfix{margin-bottom: 50px !important;}
      .sc-return-today{width: 5em;background: orange;color: #fff;}
      .sc-header select{font-size: 16px;}
      /*.sc-actions{line-height: 2em;}*/
      /*.sc-actions div{line-height: inherit;}*/

      
      /*.sc-vocation{background-color: inherit;}*/
      .sc-vocation:before{
        font-size: 12px;
        line-height: 18px;
        width: 18px;
        background-color:#FF5722;
      }
      .sc-duty{position: relative;}
      .sc-duty:before{
        position: absolute;
        content: '班';
        left: 0;top: 0;
        font-size: 12px;
        width: 18px;line-height: 18px;
        background-color: #5FB878;
        color: #fff;
      }

      /* 当前日 */
      .sc-today{position: relative;}
      .sc-today:before{
        right: 2px;top: 0;
        position: absolute;
        content: '今天';
        color: orange;
        font-size: 12px;
        line-height: 18px;
        width: 2em;
      }

      /* 鼠标激活日*/
      .sc-active-day{}

      /*标记日期*/
      .sc-mark,.sc-unmark,.sc-cmark{
        position: relative;
      }
      .sc-mark:after{
        content: '默认预约';
        color: #009688;
        position: absolute;
        font-size: 12px;
        right: 2px;bottom: 0;
        font-weight: lighter;
      }
      .sc-cmark:after{
        content: '配置预约'
      }
      .sc-unmark:after{
/*        content: '暂停预约';
        color:#FF5722;
        position: absolute;
        font-size: 12px;
        right: 2px;bottom: 0*/
      }
      .right{
        float: left;
        width: 200px;
        height: 600px;
        font-family: "Microsoft Yahei";
        color: #4A4A4A;
        box-shadow: 2px 4px 5px #bdbdbd;
        border-width: 1px 0 0 1px;
        border-color: #E6E4E0;
        border-style: solid;
        float: left;
        margin-right: 20px;
        -moz-user-select: none;
        -webkit-user-select: none;
        -ms-user-select: none;
        user-select: none;
        -webkit-text-size-adjust: none;
        font-size: 16px;
      }
      .right .layui-form-label{
        padding: 6px 0;width: 100px;text-align: left;
      }
      .right .layui-input-block{
        width: 50px;margin-left: 100px;min-height: 32px;
      }
      .right .layui-input-block .layui-input{
        height: 32px;font-size: 13px;
      }
      .right .layui-form-item{
        margin-bottom: 10px;
      }
      form{padding: 0;background-color: inherit;}


		.disabled *{
			color: #ccc!important;
			position: relative;
		}
		.disabled::after{
			color: #ccc;
		}
		.disabled::before{
		  content: "";
		  position: absolute;
		  width: 100%;
		  height: 100%;
		  left: 0;top:0;
	  }
    </style>
  </head>

  <body>
    <div id="content-wrapper">
        <div class="layui-row clearfix">
            <div id='calendar' class="layui-col-md9">
            </div>
            <div class='layui-col-md3 right'>


    <div class="layui-panel" id="view">

      <div class="layui-card-header">
          <fieldset class="layui-elem-field layui-field-title site-title">
            <legend><a name="color-design">2021-5-17</a></legend>
          </fieldset>        
      </div>

      <div class="layui-card-body" style="padding: 10px;">
          <fieldset>
            <legend><a class="layui-badge layui-bg-green">可预约时间段数量</a></legend>

            <div class="layui-form-item">
              <label class="layui-form-label">
                <input type="checkbox" name="" value='1' title="开关" checked>
                <span class="layui-badge layui-bg-gray">9:00-10:00</span>
                </label>
              <div class="layui-input-block">
                <input type="number" value="30" name="title" lay-verify="required" placeholder="数量" autocomplete="off" class="layui-input">
              </div>
            </div>
            <div class="layui-form-item">
              <label class="layui-form-label">
                <input type="checkbox" name="" value='2' title="开关" checked>
                <span class="layui-badge layui-bg-gray">11:00-12:00</span></label>
              <div class="layui-input-block">
                <input type="number" value="30" name="title" lay-verify="required" placeholder="数量" autocomplete="off" class="layui-input">
              </div>
            </div>
            <div class="layui-form-item">
              <label class="layui-form-label">
                <input type="checkbox" name="22:00-23:00" title="开关" checked>
                <span class="layui-badge layui-bg-gray">22:00-23:00</span></label>
              <div class="layui-input-block">
                <input type="number" value="30" name="title" lay-verify="required" placeholder="数量" autocomplete="off" class="layui-input">
              </div>
            </div>

          </fieldset>
          <br>
          <div class="layui-btn-container">
              <button type="button" class="layui-btn layui-btn-fluid">确认可预约数量</button>
              <button type="button" class="layui-btn layui-btn-fluid layui-btn-danger">取消预约</button>
          </div>        
      </div>

    </div>   


            </div>
        </div>
    </div>    


    <!-- 右侧确认模块模板 -->
<script id='rightTpl' type="text/html">

      <div class="layui-card-header">
          <fieldset class="layui-elem-field layui-field-title site-title">
            <legend><a name="color-design" class="layui-anim layui-anim-fadein" data-anim="layui-anim-fadein">{{ d.date}}</a></legend>
          </fieldset>        
      </div>

      <div class="layui-card-body layui-anim layui-anim-fadein" style="padding: 10px;" data-anim="layui-anim-fadein">
        <form action="">
          <fieldset>
            <legend><a class="layui-badge layui-bg-green">可预约时间段数量</a></legend>
            {{#  layui.each(d.list, function(index, item){ }}
            <div class="layui-form-item">
              <label class="layui-form-label">
                {{#  if(item.checked){ }}
                <input type="checkbox" name="typeid" data-id='{{item.id}}' title="开关" checked>
                {{#  } else { }}
                <input type="checkbox" name="typeid" data-id='{{item.id}}' title="开关" >
                {{#  } }} 
                <span class="layui-badge layui-bg-gray">{{item.title}}</span>
              </label>
              <div class="layui-input-block">
                <input type="number" value="{{item.value}}" name="typeid" data-id='{{item.id}}' placeholder="数量" autocomplete="off" class="layui-input">
              </div>
            </div>
            {{#  }); }}
          </fieldset>
          <br>
          <div class="layui-btn-container">
              <button name='submit' class="layui-btn layui-btn-fluid">确认预约及数量</button>
              <button name='cancel' class="layui-btn layui-btn-fluid layui-btn-danger">取消预约</button>
          </div>  
          </form>      
      </div>

    </div>   

</script>

<script src="https://cdn.bootcdn.net/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<!-- <script src="http://caifengye.cn/static/lib/layuiadmin/layui/layui.js"></script> -->
<script src="https://yiyuan.dabannet.cn/static/plugins/layui/layui.js"></script>
<script type="text/javascript" src="simple-calendar.js"></script>
<script>

    //可预约时间段
    var timeList = [{"id":1,"title":"8:00-9:00"},{"id":2,"title":"9:00-10:00"},{"id":3,"title":"10:00-11:00"},{"id":4,"title":"10:00-11:00"},{"id":5,"title":"14:00-15:00"},{"id":6,"title":"15:00-16:00"}];
    //可预约日期
    var dateList = [{
            date:'2021-5-17',
            status:1,
            item:[{
                time_type:1,
                time_count: 20
            },{
                time_type:2,
                time_count: 20
            },{
                time_type:3,
                time_count: 20
            }]
        },{
            date:'2021-5-18',
            status:1,
            item:[{
                time_type:1,
                time_count: 20
            }]
        },{
            date:'2021-5-20',
            status:1,
            item:[{
                time_type:2,
                time_count: 20
            },{
                time_type:3,
                time_count: 20
            },{
                time_type:4,
                time_count: 20
            }]
        },{
            date:'2021-5-19',
            status:2,
            item:[{
                time_type:1,
                time_count: 20
            },{
                time_type:2,
                time_count: 20
            },{
                time_type:3,
                time_count: 20
            }]
        },{
            date:'2021-6-2',
            status:2,
            item: null
        },{
            date:'2021-6-3',
            status:1,
            item: ''
        }
        ];
    var type = {
        addtime: 1535520601,
        advance_day: 15,
        allow_cancel_count: 2,
        allow_mun: 3,
        available_week_day: "周一,周三,周六",
        icon: "icon-list",
        id: 1,
        menustatus: 1,
        name: "Inoculate",
        pid: 0,
        quantity_down: 50,
        remind: "1、带着预约码和预防接种本；↵2、按照预约时间准时到院；↵3、过号重新现场排队。",
        time_type: "1,2",
        title: "预防接种"
    }

    var thisDateString = (new Date()).toLocaleDateString(); //"2021/5/7"
    // .sc-selected选中 .sc-festival国际节日 .sc-today今天 .sc-mark标记 .sc-vocation休息日 .sc-othermenth其他月份日期

    //定义节气
    // SimpleCalendar.prototype.languageData.solarTerm = {}
    //定义节日
    // SimpleCalendar.prototype.languageData.feativals_CH = {}

    //定义假日
    SimpleCalendar.prototype.languageData.vocation['data_2021'] = [
        '1-1','2-11','4-3','4-4','4-5','5-1', '5-2', '5-3','5-4','5-5','6-12','6-13','6-14','9-19','9-20','9-21','10-1','10-2','10-3','10-4','10-5','10-6','10-7',
    ];

    //定义假日周末上班借休
    SimpleCalendar.prototype.languageData.vocation_duty['data_2021'] = ['4-25','5-8','9-18','9-26','10-9']


    //标注
    // var defaultMark = {'2021-5-6':'预约'};
    // var defaultMark = dateList.list
    
    var options = {
        width: '688px',
        height: '600px',
        language: 'CH', //语言
        showLunarCalendar: true, //阴历
        showHoliday: true, //休假
        showFestival: true, //节日
        showLunarFestival: true, //农历节日
        showSolarTerm: true, //节气
        showMark: true, //标记
        timeRange: {
            startYear: 2000,
            endYear: 2030
        },
        mark: "",
        theme: {
            changeAble: false,
            weeks: {
                backgroundColor: '#FBEC9C',
                fontColor: '#4A4A4A',
                fontSize: '20px',
            },
            days: {
                backgroundColor: '#ffffff',
                fontColor: '#565555',
                fontSize: '24px'
            },
            todaycolor: 'orange',
            activeSelectColor: 'orange',
        }
    }

    var myCalendar = new SimpleCalendar('#calendar',options);
    

    //获取当前week 2021-5-17
    function getWeek(dateString) {
        var dateArray = dateString.split("-");
        var date = new Date(dateArray[0], parseInt(dateArray[1] - 1), dateArray[2]);
        return "周" + "日一二三四五六".charAt(date.getDay());
    }
    
    // 批量添加日期标记
    function addMarks(arr){
        for(var day in arr){
            // 次批量标注方法默认会返回当前月，暂不使用该方法
            myCalendar.addMark(day, arr[day])
            // myCalendar.addMark('2021-5-8', '预约开放')
        }
    }


    function updateMark(){
        var selectYear = myCalendar.container.querySelector('.sc-select-year').value;
        var selectMonth = myCalendar.container.querySelector('.sc-select-month').value;
        var daysElements = myCalendar.arrayfrom(myCalendar.container.querySelectorAll('.sc-item'));
        var weeks = type.available_week_day.split(',');
        for (var i = 0; i < daysElements.length; i++) {
            var element = daysElements[i].children[0];
            var date = element.innerHTML;
            var thisWeek;
            var othermonth,otheryear = selectYear;     
            if (daysElements[i].classList[1] == 'sc-othermenth') {
                //其他月日期   
                if (date.length == 2) {
                    // 日期等于2位数为上个月
                    if (selectMonth == 1) {
                        otheryear = (selectYear*1)-1
                        othermonth = 12
                    }else{
                        othermonth = (selectMonth*1)-1                        
                    }
                }           
                if (date.length == 1) {
                    // 日期等于1位数为下个月
                    if (selectMonth == 12) {
                        otheryear = (selectYear*1)+1
                        othermonth = 1
                    }else{
                        othermonth = (selectMonth*1)+1                        
                    }
                }
                thisWeek = getWeek(otheryear+'-'+othermonth+'-'+date)
            }else{
                thisWeek = getWeek(selectYear+'-'+selectMonth+'-'+date)
            }        
            for (var j = 0; j < weeks.length; j++) {
                var w1 = weeks[j];
                if(thisWeek == w1){
                  // st = selectYear+'-'+selectMonth+'-'+date
                  // myCalendar.addMark(st, '预约')
                  $(daysElements[i]).addClass('sc-mark').addClass('sc-dmark')
                  daysElements[i].title = '默认预约'
                }            
            }

            dateList.forEach(function(v){
                var markdate = v.date;
                var status = v.status;       

                if (status == 1) {
                    // 预约开放
                    if (daysElements[i].classList[1] == 'sc-othermenth') {
                        if (otheryear+'-'+othermonth+'-'+date == markdate) {
                            $(daysElements[i]).addClass('sc-mark').removeClass('sc-dmark').addClass('sc-cmark')    
                            daysElements[i].title = '配置预约'                       
                        };
                    }else{
                        if (selectYear+'-'+selectMonth+'-'+date == markdate) {
                            $(daysElements[i]).addClass('sc-mark').removeClass('sc-dmark').addClass('sc-cmark')  
                            daysElements[i].title = '配置预约'  
                        };
                    }

                }
                if (status == 2) {
                    //暂停预约
                    if (daysElements[i].classList[1] == 'sc-othermenth') {
                        if (otheryear+'-'+othermonth+'-'+date == markdate) {
                            $(daysElements[i]).removeClass('sc-mark').addClass('sc-unmark')
                            daysElements[i].title = '暂停预约'                           
                        };
                    }else{
                        if (selectYear+'-'+selectMonth+'-'+date == markdate) {
                            $(daysElements[i]).removeClass('sc-mark').addClass('sc-unmark')   
                            daysElements[i].title = '暂停预约'                         
                        };
                    }
                }
                
            })             
        }        
    }

    //更新当月默认预约日标注
    updateMark();

    $("#calendar .be-action").bind("click", function(e){
        updateMark();
    });

    layui.use(['layer','laytpl'],function(){
      // renderRight(today)
    });
  
    var d,y,m,a; //全局日期变量，操作后赋值
    var today = myCalendar.tyear+'-'+myCalendar.tmonth+'-'+myCalendar.tday;

    function _dlist(){
        // list = [{
        //   "title": '9:00-10:00',"value": '30'
        // },{
        //   "title": '10:00-11:00',"value": '30'
        // },{
        //   "title": '11:00-12:00',"value": '30'
        // },{
        //   "title": '13:00-14:00',"value": '30'
        // }]
        var list = []
        for (let i = 0; i < timeList.length; i++) {
            list[i] = {id:'',value: '',checked:'',title:''}
            list[i].value = type.quantity_down;
            list[i].checked = '';
            list[i].title = timeList[i].title
            list[i].id = timeList[i].id
            for (let j = 0; j < type.time_type.length; j++) {   
                if(timeList[i].id == type.time_type[j]){
                    list[i].checked = true
                }
            }        
        }    
        return list;    
    }

    function renderRight(day,list) {
        var a = day || today;
        var rdata = {"date":a}
        rdata.list = []

        if (list) {
            rdata.list = list          
        }else{
            rdata.list = _dlist();
        }
        // console.log(list)
        // rdata.list = list;
        var getTpl = rightTpl.innerHTML;
        var view = document.getElementById('view');      
        layui.laytpl(getTpl).render(rdata, function(html){
          view.innerHTML = html;
        });  
    }
    
    // 日期点击事件
    $(".sc-item").click(function(e){
        var selected = myCalendar.selectDay; //当前选择的日期DOM
        var selectDay = myCalendar.getSelectedDay(); //当前选择的日期时间戳
        d =selectDay.getDate();
        y =selectDay.getFullYear();
        m =selectDay.getMonth()+1;

        a = y+'-'+m+'-'+d;  //当前日期的格式化 2021-5-10

        if ($(this).hasClass('sc-othermenth')) {
            var d = $(this).children('.day').text();
            //其他月日期   
            if (d.length == 2) {
                // 日期等于2位数为上个月
                if (m == 1) {
                    y = (y*1)-1
                    m = 12
                }else{
                    m = (m*1)-1                        
                }
            }           
            if (d.length == 1) {
                // 日期等于1位数为下个月
                if (m == 12) {
                    y = (y*1)+1
                    m = 1
                }else{
                    m = (m*1)+1                        
                }
            }
            a = y+'-'+m+'-'+d;  //换算当前日期的格式化 2021-5-10         
        }

		var thisTimeList = _dlist();
        if ($(this).hasClass('sc-mark')) {
            // console.log('已标记')
            var list = []
            // 1,默认标记；2，配置标记，3，禁用标记
            
            var thisItem = ""
			//数据中有当前点击的日期
            dateList.forEach(function(v){
                if(v.date == a){
                    if (v.item && v.item.length) {
                        thisItem = v;                        
                    }
                }
            })

			if (thisItem) {	
				//遍历日期配置时间及数量				
				for (let i = 0; i < thisTimeList.length; i++) {
					thisTimeList[i].checked = "";
					thisItem.item.forEach(function(f){
						// f.time_type
						// f.time_count
						if(thisTimeList[i].id == f.time_type){
							thisTimeList[i].checked = true;
							thisTimeList[i].value = f.time_count;                                    
						}
					})					
					list.push(thisTimeList[i]);          
				}
            }else{
				list = _dlist();
				for (let i = 0; i < list.length; i++) {
					list[i].checked = "";					
				}
			}

            if ($(this).hasClass('sc-dmark')) {
                renderRight(a,)
            }
            if ($(this).hasClass('sc-cmark')) {
                renderRight(a,list)
            }

        }else{
			list = _dlist();
			for (let i = 0; i < list.length; i++) {
				list[i].checked = "";					
			}
            renderRight(a,list)
            // console.log('未标记')           
        }
    })


    $('#view').on('click',':submit',function(e){
        event.preventDefault();
        var selectDay = myCalendar.selectDay;
        var list = {
            date: a,
            status: 1,
            item:[]
        }
        if(e.currentTarget.name == 'submit'){
            // console.log('submit',e)
            var form = e.currentTarget.form
            var $inputs = $(form).find('input')
            for (var i = 0; i < $inputs.length; i++) {
                if($inputs[i].checked){
                    // $inputs[i]
                    var id = $inputs[i].dataset.id; //time_type
                    var value = $inputs[i+1].value; //time_count

                    list.status = 1
                    list.item.push({
                        time_type: id,
                        time_count: value
                    })
                }
            };


            layer.confirm('确认修改【'+a+'】预约？',{
                btn: ['确认','返回']
            },function(index){

                var newDate = true;
                dateList.forEach(function(v){
                    var o = v; //旧数据
                    var n = list; //新数据
                    if(o.date == n.date){
                        newDate = false
                        //修改                    
                        o.item = n.item
						o.status = 1
                    }
                })
                if (newDate) {
                    dateList.push(list)                
                }


                $(selectDay).addClass('sc-mark').addClass('sc-cmark');
                layer.close(index)

            })

        }
        if (e.currentTarget.name == 'cancel' && $(selectDay).hasClass('sc-mark')) {
            console.log('cancel')

            layer.confirm('是否确认取消', {
                btn: ['确认', '返回'] //可以无限个按钮
            }, function(index, layero){
                //按钮【按钮一】的回调

                var newDate = true
                dateList.forEach(function(v,key){
                  	if(v.date == a){
						//有当前选定日期记录，修改记录
						v.status = 2;
						newDate = false
                    }
                })
                if (newDate) {
                    list.status = 2
                    dateList.push(list)
                }

                // delete myCalendar._options.mark[a];
                $(selectDay).removeClass('sc-mark').removeClass('sc-cmark').removeClass('sc-dmark');
                layer.close(index)

            });

        }
                
    })



</script>


</body>
</html>